1 00:00:00,630 --> 00:00:04,500 Hello and welcome to this little shop in this little show. 2 00:00:04,530 --> 00:00:08,310 We will be moving the ball. 3 00:00:08,310 --> 00:00:11,490 This is what the ball looks like at the moment. 4 00:00:11,880 --> 00:00:19,080 We have got the x and y coordinates hard coded with these values. 5 00:00:19,080 --> 00:00:30,330 What we will do to change the position of the ball we are going to create two variables for the x and 6 00:00:30,330 --> 00:00:37,900 y that we'll use to replace these hard coded values. 7 00:00:38,370 --> 00:00:49,020 The variables that we will create for the x and y y coordinates will be used to define the position 8 00:00:49,260 --> 00:00:53,930 at which the ball is drawn at. 9 00:00:53,980 --> 00:00:55,960 All right let's quit the variable. 10 00:00:56,250 --> 00:01:00,470 What I like to do is I want t to start. 11 00:01:00,540 --> 00:01:09,630 Want the want the board game to start from the bottom centre part of the comforts so when I defined 12 00:01:09,640 --> 00:01:21,900 the variable each will reflect starting from the bottom centre part of the compass so to create the 13 00:01:21,900 --> 00:01:33,630 variable type in the one var and then give the x the value of the name on the variable we'll call it 14 00:01:33,750 --> 00:01:44,280 X and will give it a value off of the canvass variable dot 15 00:01:47,100 --> 00:01:47,550 with 16 00:01:50,550 --> 00:01:53,070 Divide by two. 17 00:01:53,550 --> 00:02:04,440 So this will be the value for the X ordinate way replacing this hard coded value here where is variable. 18 00:02:04,790 --> 00:02:12,630 That will create another variable for the Y which is B R and then we give the value 19 00:02:15,300 --> 00:02:16,160 canvas 20 00:02:18,660 --> 00:02:19,860 dot height 21 00:02:23,730 --> 00:02:27,930 minus 30. 22 00:02:28,350 --> 00:02:38,070 So these variables we make the movement of the ball pronounced the more meant you can't tell that the 23 00:02:38,080 --> 00:02:43,850 circle is been painted on the canvas every 10 milliseconds. 24 00:02:44,010 --> 00:02:53,420 By declaring these variables we can see some activity on the ball moving. 25 00:02:53,430 --> 00:03:02,490 Note that every time the ball is painted on the screen is referred to as a frame so each page tin instance 26 00:03:02,850 --> 00:03:05,080 is a frame. 27 00:03:05,340 --> 00:03:16,320 We'll need to add a small value to the X and Y variable so that after every frame is painted on the 28 00:03:16,320 --> 00:03:22,740 canvas or is drawn under cover it will appear that the ball is moving. 29 00:03:22,740 --> 00:03:33,050 So to do this we need to define variable to variables extra variables that will represent these movements. 30 00:03:33,450 --> 00:03:36,650 So let's create the variables here as well. 31 00:03:36,720 --> 00:03:50,000 So we'll define the first one variable D takes and give it a value of. 32 00:03:50,690 --> 00:03:51,360 To. 33 00:03:54,440 --> 00:04:07,740 Next quit variable d y and give it a value of minus 2. 34 00:04:11,050 --> 00:04:22,340 K What we need to do will need to update this drol function so that every time frame in New frame is 35 00:04:22,440 --> 00:04:28,110 painted it updates the X and Y variable. 36 00:04:28,260 --> 00:04:37,820 What that means that on every frame the X and Y variable will be updated with the D X and D Y variable 37 00:04:37,940 --> 00:04:39,640 on every frame. 38 00:04:39,860 --> 00:04:40,710 So what they'll do. 39 00:04:40,710 --> 00:04:49,970 It will make it will make it appear that the ball is painted in a new position on every object. 40 00:04:50,840 --> 00:04:53,110 So let's update this function. 41 00:04:53,360 --> 00:04:58,950 The first time will need to do is change is hard coded value and replace that with. 42 00:05:00,820 --> 00:05:02,540 The eggs variable. 43 00:05:04,400 --> 00:05:10,220 Hand or Y variable. 44 00:05:11,140 --> 00:05:22,150 I'm going to change the radius from 20 to 10 and then the rest will say live the refs the same. 45 00:05:22,150 --> 00:05:30,620 This value here the force option is optional so we can skip that remove that. 46 00:05:30,620 --> 00:05:34,600 I am going to remove that because it is optional. 47 00:05:34,600 --> 00:05:46,690 Finally we need to represent the D X and d d y values so we'll put that just have the bottom before 48 00:05:47,470 --> 00:05:52,460 we close the before this close and curly braces. 49 00:05:52,840 --> 00:05:55,450 So what do we do. 50 00:05:55,510 --> 00:06:14,340 X the value of x plus EPOS to do X and Y loss equates to the Y. 51 00:06:15,110 --> 00:06:18,580 All right saw that on every frame. 52 00:06:18,580 --> 00:06:25,980 The x variable will be updated with this and the Y would be updated with that. 53 00:06:26,090 --> 00:06:29,610 So save this. 54 00:06:30,220 --> 00:06:36,850 All right so let me refresh this so you can see it appears. 55 00:06:36,880 --> 00:06:38,330 Let me refresh that again. 56 00:06:38,500 --> 00:06:45,320 You can see that the movement may refresh consider a moment all right. 57 00:06:45,730 --> 00:06:53,180 What it does it looks appears as if the board is moving bot leaving a trail behind it. 58 00:06:53,200 --> 00:06:54,720 That's why it looks likes on fire. 59 00:06:54,720 --> 00:06:57,240 Run this again and see the ball move in. 60 00:06:57,250 --> 00:07:01,600 It appears it's leaving a tree behind it. 61 00:07:01,600 --> 00:07:10,450 The reason it appears that leaving a trail is because each time frame is painted for the new circle 62 00:07:10,450 --> 00:07:11,700 or new born. 63 00:07:11,740 --> 00:07:18,250 It does not remove the previous one so it has them all together and with continuous trail. 64 00:07:18,430 --> 00:07:26,860 So in the next leg election we can all learn how to clear a compass before each frame. 65 00:07:26,860 --> 00:07:29,010 That way you can see the ball. 66 00:07:29,030 --> 00:07:35,860 They define the moment they collect in the frames and not clearing up after each other is form a continuous 67 00:07:35,860 --> 00:07:36,840 trail. 68 00:07:37,390 --> 00:07:38,990 That's it for this lecture. 69 00:07:39,010 --> 00:07:41,410 Thanks for watching in the next lecture. 70 00:07:41,690 --> 00:07:51,220 We will try and clear each of the frame so that you can see the individual ball at other time on the 71 00:07:51,460 --> 00:07:52,670 compass. 72 00:07:52,690 --> 00:07:54,560 Take care and by phone.